/**
 * 路由导航
 * @author 杨世峰、韩睿倩
 */

import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'LoginPage',
        component: () => import('@/views/login.vue'),
    },
    {
        path: '/login',
        redirect: '/'
    },
    {
        path: '/register',
        name: 'RegisterPage',
        component: () => import('@/views/register.vue'),
    },
    {
        path: '/userhome',
        name: 'UserHome',
        component: () => import('@/views/user/userHome.vue'),
        children: [
            {
                path: '',
                name: 'Dict',
                component: () => import('@/views/user/dict.vue')
            },
            {
                path: 'person',
                name: 'PersonalCenter',
                component: () => import('@/views/user/userPersennalCenter.vue')
            },
            {
                path: 'dict',
                redirect: '/userhome/'
            },
            {
                path: 'booklets',
                name: 'Booklets',
                component : () => import('@/views/user/bookletList.vue')
            },
            {
                path: 'shares',
                name: 'ShareBooklets',
                component : () => import('@/views/user/shareBookletList.vue')
            },
            {
                path: 'learn',
                name: 'LearnWords',
                component : () => import('@/views/user/studyPage.vue')
            }
        ]
    },
    {
        path: '/administratorHome',
        name: 'AdministratorHomePage',
        component: () => import('@/views/administrator/administratorHome.vue'),
        children: [
            {
                path: 'userManagement',
                name: 'UserManagement',
                component: () => import('@/views/administrator/userManagement.vue'),
                
            },
            {
                path: 'userInfoPage',
                name: 'UserInfoPage',
                component: () => import('@/views/administrator/userInfoPage.vue')
            },
            {
                path: 'functionManagement',
                name: 'FunctionManagement',
                component: () => import('@/views/administrator/functionManagement.vue')
            },
            {
                path: 'thesaurusModule',
                name: 'ThesaurusModule',
                component: () => import('@/views/administrator/thesaurusModule.vue')
            },
            
            // 单词本模块，词典模块

            {
                path: 'booklets',
                name: 'Booklets',
                component : () => import('@/views/user/bookletList.vue')
            },
            {
                path: '',
                name: 'Dict',
                component: () => import('@/views/user/dict.vue')
            },
            
            {
                path: 'wordInfoPage',
                name: 'wordInfoPage',
                component: () => import('@/views/administrator/wordInfoPage.vue')
            },    
            {
                path: 'socialManagement',
                name: 'SocialManagement',
                component: () => import('@/views/administrator/socialManagement.vue')
            },
            {
                path: 'adminInfoPage',
                name: 'adminInfoPage',
                component: () => import('@/views/administrator/adminInfoPage.vue')
            },
            {
                path: 'learnAdmin',
                name: 'LearnWordsAdmin',
                component : () => import('@/views/user/studyPage.vue')
            },
            {
                path: 'bookletsAdmin',
                name: 'BookletsAdmin',
                component : () => import('@/views/user/bookletList.vue')
            },

        ]

    }

]

const router = new VueRouter({
    mode: 'history',
    routes
})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

export default router